package com.home.biz;/**
 * @author chenxf
 * @date 2022/4/15 15:23
 */

import com.home.base.biz.BaseBiz;
import com.home.entity.PolicySiteConfig;
import com.home.mapper.PolicySiteConfigMapper;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

/**
 * @author chenxf
 * @date 2022/4/15 15:23
 */
@Service
public class PolicySiteConfigBiz extends BaseBiz<PolicySiteConfigMapper, PolicySiteConfig> {

    public PolicySiteConfig fetchOneSite(){
//        return selectById(140);
        Example example=new Example(PolicySiteConfig.class);
        Example.Criteria criteria=example.createCriteria();
        criteria.andEqualTo("status",1);
        criteria.andLessThan("fetchTime", LocalDate.now().atTime(LocalTime.MIDNIGHT));
        criteria.orIsNull("fetchTime");
        example.setOrderByClause(" id asc limit 1");
        List<PolicySiteConfig> list=selectByExample(example);
        if(list.size()>0){
            return list.get(0);
        }
        return null;
    }
}
